// 创建一组主题对象类型的抽象类
class AnimalFood {
    provide () {
        throw new Error('....')
    }
}

class AnimalToy {
    provide () {
        throw new Error('....')
    }
}

// 创建一组具体代表家族的对象
class HighQualityDogFood extends AnimalFood {
    provide () {
        return '高级狗粮'
    }
}
class HighQualityDogToy extends AnimalToy {
    provide () {
        return '高级狗玩具'
    }
}
class CheapCatFood extends AnimalFood {
    provide () {
        return '便宜猫粮'
    }
}
class CheapCatToy extends AnimalToy {
    provide () {
        return '便宜猫玩具'
    }
}

// 创建一个抽象工厂
class AnimalProductsAbstractFactory {
    createFood () {
        throw new Error('...')
    }
    createToy () {
        throw new Error('...')
    }
}

// 创建具体工厂
class HighQualityAnimalProductsFactory extends AnimalProductsAbstractFactory {
    createFood () {
        return new HighQualityDogFood()
    }
    createToy () {
        return new HighQualityDogToy()
    }
}
class CheapAnimalProductsFactory extends AnimalProductsAbstractFactory {
    createFood () {
        return new CheapCatFood()
    }
    createToy () {
        return new CheapCatToy()
    }
}

// 使用具体工厂类来创建相关对象
const highQualityAnimalProductsFactory = new HighQualityAnimalProductsFactory()
console.log(highQualityAnimalProductsFactory.createFood().provide())
console.log(highQualityAnimalProductsFactory.createToy().provide())

const cheapAnimalProductsFactory = new CheapAnimalProductsFactory()
console.log(cheapAnimalProductsFactory.createFood().provide())
console.log(cheapAnimalProductsFactory.createToy().provide())
